<?php
// nav active links
$homeCl = "";
$listingCl = "";
$listingAddCl = "";
$offerCl = "";
$eventCl = "";
$userCl = "";
$advSearchCl = "";
$regCl ="";
$profileCl="";
$reviewsCl="";

$url = $this->params['url']['url'];
if($url == "/")
{
    $homeCl = "active";    
}
if($url == "listings")
{
    $listingCl = "active";    
}
if($url == "listings/add")
{
    $listingAddCl = "active";    
}
if($url == "deals/deals/index/")
{
    $offerCl = "active";    
}
if($url == "events/events/index")
{
    $eventCl = "active";    
}
if($url == "users")
{
    $userCl = "active";    
}
if($url == "listings/advancedSearch")
{
    $advSearchCl = "active";    
}
if($url == "users/register")
{
    $regCl = "active";    
}
if($url == "users/profile")
{
    $profileCl = "active";    
}
if($url == "reviews")
{
    $reviewsCl = "active";    
}
?>
<div class="navbar-collapse pull-left collapse">
        <ul class="nav navbar-nav">
                <li class="<?php echo $homeCl; ?>">
                        <?php echo $html->link(__('Home'),'/');?>
                </li>

                <li class="<?php echo $listingCl; ?>">
                        <?php echo $html->link(__('Listings'),'/listings');?>
                </li> 
                <?php /*
                <li class="<?php echo $reviewsCl; ?>">
                        <?php echo $html->link(__('Reviews'),'/reviews');?>
                </li>
				<?php*/
					if($session->read("Auth.User.id") && (cr('ListingConfig.listing_add_only_by_editor') != 1 || $session->read('Auth.User.is_editor') == 1)) 
					{?><li class="<?php echo $listingAddCl; ?>"><?php
						echo $html->link(__('Add Listing'),'/listings/add');?>	</li><?php
					}
					/*
				?>
                <li class="<?php echo $userCl; ?>">
                        <?php echo $html->link(__('Users'),'/users');?>
                </li>

                <?php if(@$session->read('Auth.User'))
                {?>
                <li class="<?php echo $profileCl; ?>">
                        <?php echo $html->link(__('My Account'),'/users/profile');?>
                </li>
                <?php }else{?>
                <li class="<?php echo $regCl; ?>">
                        <?php echo $html->link(__('Register'),'/users/register');?>
                </li>
                <?php }?>
                */ ?>
                <?php if(cr("DealConfig.enable_deals")) { ?>
                        <li class="<?php echo $offerCl; ?>">
                                <?php echo $html->link(__('Deals'),'/deals/deals/index');?>
                        </li>
                <?php } ?>
                <?php if(cr("EventConfig.enable_events")) { ?>
                        <li class="<?php echo $eventCl; ?>">
                                <?php echo $html->link(__('Events'),'/events/events/index');?>
                        </li>
                <?php } ?>
                <li class="<?php echo $advSearchCl; ?>">
                        <?php echo $html->link(__('Search'),'/listings/advancedSearch');?>
                </li>
                
        </ul>
</div>
<?php if(@$session->read('Auth.User'))
            {?>

<!--<div class="sign_in">
        <a href="#" class="sign_btn_1"><?php echo __("My Account");?><span class="caret"></span></a>
        <div class="sign_up_box">
        <?php 
            //echo $this->element('loginBox');
        ?>
        </div>
    </div>-->
<?php $authedUser = $session->read('Auth.User');?>
<div id="logged" class="link_right">
	<ul class="nav nav-pills"> 
		<li role="presentation" class="dropdown">
			<a class="dropdown-toggle" data-toggle="dropdown" href="javascript:void(0);" role="button" aria-expanded="false" style="border:none;">
			  <?php echo __("My Account");?> <i class="fa fa-angle-down"></i>
			</a> 
			 <ul class="dropdown-menu styled_list" role="menu"> 
				<li class="welcome"><a class="" title=""><?php echo __("Welcome");?>, <?php echo $authedUser['display_name'];?></a></li>
				<li><i class="fa fa-user"></i><?php echo $html->link(__('My Account'), '/users/profile',array('class'=>'account'));?></li>
				<li><i class="fa fa-envelope"></i><?php echo $html->link(__('My Inbox',true),'/messages/index/inbox',array('class'=>'inbox'))."<br>";?></li>
				<li><i class="fa fa-power-off"></i><?php echo $html->link(__('Logout'), '/users/logout',array('class'=>'logout'));?></li>
			</ul>
		</li> 
	</ul>  
</div><!--link_right-->
<?php }else{?>
	<div class="link_right">
		<ul class="nav nav-pills">
			<li><?php echo $html->link(__('Register'),'/users/register');?></li>
			<li role="presentation" class="dropdown"><a class="dropdown-toggle" data-toggle="modal" data-target="#LoginModal" href="#" role="button" aria-expanded="false">Sign in</a></li>
		</ul>
		<?php 
			echo $this->element('loginBox');
		?>
	</div>
<?php }?>
